package cn.doitedu.commons.utils

import org.apache.log4j.{Level, Logger}
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession

object SparkUtil {

  def getSparkSession(name:String = "",master:String="local",conf:Map[String,String]=Map.empty):SparkSession ={

    Logger.getLogger("org").setLevel(Level.WARN)

    val cf = new SparkConf()
    cf.set("spark.sql.shuffle.partitions","10")
    cf.setAll(conf)

    SparkSession.builder()
      .appName(name)
      .master(master)
      .config(cf)
      .enableHiveSupport()
      .getOrCreate()
  }

}
